package com.company.service.impl;

import com.company.entity.User;
import com.company.service.RegistService;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class RegistServiceImpl implements RegistService {



    @Override
    public void execute(List list) {
        while (true){

            User user = new User();
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入姓名：");
            user.setUsername(sc.next());
            System.out.println("请输入密码：");
            user.setPassword(sc.next());
            System.out.println("请再次输入密码");
            String pwd = sc.next();
            if (!user.getPassword().equals(pwd)){
                System.out.println("两次输入密码不同");
                continue;

            }
            if (user.getPassword().length()<6){
                System.out.println("密码不能小于六位");
                continue;
            }
            if (user.getUsername()!=null||(user.getPassword()!=null)){

                list.add(user);
                System.out.println("注册成功");
                break;



            }


        }
    }
}
